<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class RunGameReward extends Model
{
    public $timestamps = false;
    protected $table = "run_game_reward";

    const USE_NO = 0;
    const USE_YES = 1;

    static $UseDisplay = [
        self::USE_NO=>'禁用',
        self::USE_YES=>'使用',
    ];

    /**
     * 添加奖品
     * @param $request
     * @return array
     */
    static function RewardAdd($request)
    {
        $reward = new RunGameReward();
        $reward->title = $request->title;
        $reward->ranking = $request->ranking;
        $reward->start_at = strtotime($request->start_at);
        $reward->img = $request->img;
        $reward->detail = $request->detail;
        $reward->created_at = time();
        if (!$reward->save()) {
            return ['status' => 2, 'message' => '失败'];
        }
        return ['status' => 1, 'message' => '成功'];
    }
}
